package com.gzy.rpsm_admin.pojo.user;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.DigestUtils;

import java.nio.charset.StandardCharsets;

@Data
@ApiModel("用于登录的用户类")
public class LoginUser extends ResUser{
    @ApiModelProperty("用户密码")
    private String password;

    @Override
    public String toString() {
        return "LoginUser{" +
                "password='" + password + '\'' +
                "} " + super.toString();
    }
    public void setPassword(String password) {
        if (password.length() != 32) {
            this.password = DigestUtils.md5DigestAsHex(password.getBytes(StandardCharsets.UTF_8));
        } else {
            this.password = password;
        }
    }
}
